/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package components;

import GUInemeanshop.GUIContent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.JButton;
import nemeanshop.NemeanShop;

/**
 *
 * @author havardaxelsen
 */
public class NButton extends JButton{
    
    private Color c             = new Color(0,0,0, 120);
    private Dimension dim       = new Dimension(100,30);

    private GUIContent gc;
    private NemeanShop ns;


    public NButton(String string, ActionListener k) {
        this.setText(string);
        this.setBackground(null);
        this.addActionListener(k);
        this.setPreferredSize(dim);
        this.setMinimumSize(dim);
        this.setBorder(null);
        this.setFocusable(false);
    }
    public NButton(String tekst){
        this.setText(tekst);
        this.setBackground(null);
        this.setPreferredSize(dim);
        this.setMinimumSize(dim);
        this.setBorder(null);
        this.setFocusable(false);
    }
    
    public NButton (Icon i, String tooltip){
        
        
        
        this.setToolTipText(tooltip);
        this.setPreferredSize(dim);
        this.setMinimumSize(dim);
        //this.setBorder(null);
        this.setBackground(null);
        this.setIcon(i);
        this.setRolloverIcon(i);
        this.setRolloverEnabled(true);
        this.setFocusable(false);
        
    }
    
    public NButton(String tekst, final GUIContent gc, final String s){
        this.setText(tekst);
        this.setBackground(null);
        this.setPreferredSize(dim);
        this.setMinimumSize(dim);
        this.setBorder(null);
        this.setFocusable(false);
        
        this.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae)
            {
                gc.showCard(s);
                
            }
        });
    }
    
    
    public NButton(String tip, Icon i, Icon imo, final GUIContent gc, final String s){
        this.setIcon(i);
        this.setBackground(null);
        this.setToolTipText(tip);
        this.setRolloverEnabled(true);
        this.setRolloverIcon(imo);
        this.setPreferredSize(dim);
        this.setContentAreaFilled(false); 
        this.setFocusPainted(false);
        this.setMinimumSize(dim);
        this.setBorder(null);
        this.setFocusable(false);
        
        this.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae)
            {
                
                if (s.equals("PRODUKTLISTE"))
                {
                    EventQueue.invokeLater(new Runnable(){
                        @Override
                        public void run()
                        {
                            gc.updateGUIProductList();
                        }
                    });
                }
                gc.showCard(s);
            }
        });
    }
    
    public NButton(String tip, Icon i, Icon imo, final GUIContent gc, final String s, final NemeanShop ns){
        this.setIcon(i);
        this.ns = ns;
        this.setToolTipText(tip);
        this.setRolloverEnabled(true);
        this.setContentAreaFilled(false); 
        this.setFocusPainted(false);
        this.setRolloverIcon(imo);
        this.setBackground(null);
        this.setPreferredSize(dim);
        this.setMinimumSize(dim);
        this.setBorder(null);
        this.setFocusable(false);
        
        this.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae)
            {
                
                gc.showCard(s);
                ns.removeCashier();
                gc.logOut();
            }
        });
    }

        
 }

    

